﻿Imports System.Text.RegularExpressions

Namespace Util

    Friend NotInheritable Class RegexUtil
        Private Sub New()
        End Sub
        ''' <summary>
        '''     Match the given texts (string) with the given pattern
        ''' </summary>
        ''' <param name="pattern">
        '''     The pattern of Regular Expression
        ''' </param>
        ''' <param name="texts">
        '''     The string that needed to be matched against to pattern.
        ''' </param>
        ''' <returns>
        '''     Return null if there is no match. Otherwise, return
        '''     an array of string.
        ''' </returns>
        Friend Shared Function Match(pattern As String, texts As String) As Boolean
            If pattern Is Nothing OrElse texts Is Nothing Then
                Return False
            End If

            Dim matches = Regex.Matches(texts, pattern)

            If matches.Count = 0 Then
                Return False
            End If
            Return True
        End Function
    End Class
End Namespace
